//
//  CollectionViewCell.m
//  SecondMeView
//
//  Created by lanou on 15/12/18.
//  Copyright © 2015年 吴昊. All rights reserved.
//

#import "CollectionViewCell.h"
#import "UIImageView+AFNetworking.h"

@implementation CollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        
        CGFloat totalWtidth = self.frame.size.width;
        CGFloat totalHeigth = self.frame.size.height;
        _pictureView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, totalWtidth, totalHeigth)];
        [self addSubview:_pictureView];
        _blackView = [[UIView alloc]initWithFrame:(CGRectMake(0, totalHeigth - 30, totalWtidth, 30))];
        _blackView.backgroundColor = [UIColor blackColor];
        _blackView.alpha = 0.2;
        [_pictureView addSubview:_blackView];
        
        _loveButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
        _loveButton.frame = CGRectMake(15, totalHeigth - 28, 25, 25);
        [_loveButton setImage:[UIImage imageNamed:@"已收藏"] forState:(UIControlStateNormal)];
        [self addSubview:_loveButton];
    
        _addButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
        _addButton.frame = CGRectMake(100, totalHeigth - 28, 25, 25);
        [_addButton setImage:[UIImage imageNamed:@"已收藏"] forState:(UIControlStateNormal)];
        [self addSubview:_addButton];
        _addNumberLabel = [[UILabel alloc]initWithFrame:(CGRectMake(kWidth/3 +15,totalHeigth - 30, 60, 30))];
        _addNumberLabel.textColor = [UIColor whiteColor];
        [self addSubview:_addNumberLabel];
    
        
    }
    return self;
}


- (void)setPicture:(Picture *)picture{
    if (_picture != picture) {
        _picture = picture;
     
        [_pictureView setImageWithURL:[NSURL URLWithString:picture.pic]];
    
        _addNumberLabel.text = picture.col_count;
    }
    
    
}



@end
